<?php
	# Languages
		// Init default language, if not initilize.
			//if(!$_SESSION['lang']) $_SESSION['lang'] = DEFAULT_LANGUAGE;
					
		if(isset($init['error'])) {
			echo"<b>Errors report:</b><br /> \n";
			print_r($init['error']);
			
			exit;
		}
		
	# Session initiling
		@$ses_id=$_COOKIE[session_name()];
		if(isset($_POST['PHPSESSID'])) {
			session_id($_POST['PHPSESSID']);
			session_start();
		} elseif(isset($_GET['PHPSESSID'])) {
			session_id($_GET['PHPSESSID']);
			session_start();
		} elseif (empty($ses_id)){
			session_start();
			$ses_id=session_id();
			//setcookie(session_name(),session_id(),time()+2678400);
		}
		else {
			session_id($ses_id);
			session_start();
		}
		
		if(is_file('./sys/sessions/'.session_id())) {
			$_SESSION = unserialize(implode(file('./sys/sessions/'.session_id())));
		}
		
		//print_r($_SESSION);
	# Init patches
		if(isset($config['os']['pear'])) {
    		ini_set('include_path', $config['os']['pear']);
        }
        
    # _SESSION functions
	
		function save_session_now($before = './') {
			$session = fopen($before.'sys/sessions/'.session_id(), "w");
			fwrite($session, serialize($_SESSION));
			fclose($session);
		}
?>
